package com.atguigu.gulimall.seckill.schedualed;

import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit;

/**
 * @author 马迎迎
 * @Title: HelloSchedual
 * @Package com.atguigu.gulimall.seckill.schedualed
 * @Description: TODO(添加描述)
 * @date 2021年06月02日 10:52
 */
/**
 * 1.@EnableScheduling开启定时任务
 */
@Component
//@EnableScheduling
//@EnableAsync
@Slf4j
public class HelloSchedual {
    /**
     * 1.spring中cron由6位组成，不允许第七位的年
     * 2.在周几的位置 1-7代表周一-周日
     * 3.定时任务不应该阻塞
     */
//    @Async
//    @Scheduled(cron = "* * * * * ?")
//    public void hello(){
//        log.info("hello...");
//        try {
//            TimeUnit.SECONDS.sleep(3);
//        } catch(InterruptedException e) {
//            e.printStackTrace();
//        }
////        CompletableFuture.runAsync(()->{
////            xxxService.hello();
////        },executor);
//
//    }
}
